package games.platformer.behaviors;

import vooga.entities.Entity;
import vooga.behaviors.*;
import games.platformer.Level;
import vooga.core.Sound;



/**
 * Fall Down And Die Behavior - you die and make a horrible sound when you fall past the bottom of the screen
 * 
 * created 12-10
 * @author Ben Shelton
 * @author Congyi Wu
 */
public class FallDownAndDie extends AbstractBehavior
{

	Level myLevel;
	
	private int myDeathHeight;
	
	private vooga.core.Sound mySound;
	
    public FallDownAndDie(int deathHeight, Level level, String sound)
    {
    	myDeathHeight = deathHeight;
    	myLevel = level;
    	mySound = new Sound(sound);
    }
    
    /**
     * if the player character falls below the specified death height, they die
     */
    public void step (Entity target)
    {
    	if(target.getBottom() > myDeathHeight)
    	{
    		mySound.play();
    		myLevel.loseLife();
    	}    
    }
}
